|
|
|
BlueCielo Meridian Enterprise 2012 Developer's Guide | BlueCielo ECM Solutions |
You can initialize the properties of a new document using VBScript. This can be a handy feature when importing multiple documents and some properties are the same for all the documents. The user would not have to enter the values manually in the wizard for each document.
The following sample code demonstrates how to use the Batch object’s Argument property to save the values of some hypothetical properties entered for the first document of a batch for reuse with the remainder of the documents. It also demonstrates the correct events to extend and calling supporting methods.
Sub DocGenericEvent_BeforeNewDocument(Batch, Action, SourceFile, DocType, DocTemplate)
' This code shows how to initialize the property values for new documents.
bInitializeProperties = False
' You can (for example) limit this to Importing and Batchscan
If (Action = AS_IT_IMPORTED) Or (Action = AS_IT_BATCHSCAN) Then
' Or any other criteria
bInitializeProperties = DoYouWantToInitializeThePropertyValues(DocType)
End If
If bInitializeProperties Then
' Here we initialize the document properties
' This saves the user from having to type these values in the wizard
InitializeDocumentProperty Batch, Document, DocType
' You can also initialize a property with a fixed value
Document.Language = "English"
' Or you can store information about the import in a property
If Action = AS_IT_IMPORTED Then
Document.Source = "Imported at " & _
GMTTime2Local(Vault.ServerTimeGMT) & _
" ( " & Batch.BatchIndex & " of " & Batch.BatchSize & " ) "
ElseIf Action = AS_IT_AS_IT_BATCHSCAN Then
Document.Source = "Scanned at " & _ GMTTime2Local(Vault.ServerTimeGMT) & _
" ( " & Batch.BatchIndex & " of " & Batch.BatchSize & " ) "
End If
End If
End Sub Sub DocGenericEvent_AfterNewDocument(Batch, Action, SourceFile, DocType, DocTemplate)
' When the new document is created, we store the property values that we ' will use to initialize the next document
bInitializeProperties = False
' You can (for example) limit this to importing and batch scanning
If (Action = AS_IT_IMPORTED) Or (Action = AS_IT_BATCHSCAN) Then
' Or any other criteria
bInitializeProperties = DoYouWantToInitializeThePropertyValues(DocType)
End If
If bInitializeProperties Then
StoreDocumentPropertyForThisBatch Batch, Document, DocType
End If
End Sub ' Using custom procedures, we keep the implementation of the events readable
' Custom procedure used in the 'AfterNewDocument' event
Sub StoreDocumentPropertyForThisBatch(Batch, Document, DocType)
' The 'Argument' property of the 'Batch' object is used to store
' information within the context of the current batch operation.
' Store the values entered for this document to reuse them for the next document(s) in the batch
Batch.Argument ("Productname") = Document.Productname
Batch.Argument ("Order") = Document.Order
Batch.Argument ("ArticleNumber") = Document.ArticleNumber
' Some properties might depend on the document type
' So we store the value in an argument that includes the document type name
Batch.Argument ("Material_" & DocType.InternalName) = Document.Material
Batch.Argument ("Length_" & DocType.InternalName) = Document.Length
Batch.Argument ("Height_" & DocType.InternalName) = Document.Height
Batch.Argument ("Treatment_" & DocType.InternalName) = Document.Treatment
Batch.Argument ("Width_" & DocType.InternalName) = Document.Width
Batch.Argument ("Weight_" & DocType.InternalName) = Document.Weight
Batch.Argument ("Tolerance_" & DocType.InternalName) = Document.Tolerance
Batch.Argument ("Finish_" & DocType.InternalName) = Document.Finish
End Sub ' Custom procedure used in the 'BeforeNewDocument' event
Sub InitializeDocumentProperty(Batch, Document, DocType)
' Initialize the new document with values stored from a previous document
Document.Productname = Batch.Argument ("Productname")
Document.Order = Batch.Argument ("Order")
Document.ArticleNumber = Batch.Argument ("ArticleNumber")
' Some properties might depend on the document type
' So we get the value from the argument that includes the doc type name
Document.Material = Batch.Argument ("Material_" & DocType.InternalName)
Document.Length = Batch.Argument ("Length_" & DocType.InternalName)
Document.Height = Batch.Argument ("Height_" & DocType.InternalName)
Document.Treatment = Batch.Argument ("Treatment_" & DocType.InternalName)
Document.Width = Batch.Argument ("Width_" & DocType.InternalName)
Document.Weight = Batch.Argument ("Weight_" & DocType.InternalName)
Document.Tolerance = Batch.Argument ("Tolerance_" & DocType.InternalName)
Document.Finish = Batch.Argument ("Finish_" & DocType.InternalName)
End Sub ' Custom function used in the 'BeforeNewDocument' and 'AfterNewDocument' event
Function DoYouWantToInitializeThePropertyValues(DocType)
DoYouWantToInitializeThePropertyValues = True
If DocType.InternalName = "GenericDocument" Then
' For example exclude Generic Documents
DoYouWantToInitializeThePropertyValues = False
End If
End Function
Copyright © 2000-2012 BlueCielo ECM Solutions |